public class test1 {
    public int evalRPN(String[] tokens) {
        Deque<Integer> stack = new LinkedList<>();
        for(String t:tokens){
            if(t.equals("+")){
                stack.push(stack.pop()+stack.pop());
            }else if(t.equals("*")){
                stack.push(stack.pop()*stack.pop());
            }else if(t.equals("-")){
                stack.push(-stack.pop()+stack.pop());
            }else if(t.equals("/")){
                int tmp1 = stack.pop();
                int tmp2 = stack.pop();
                stack.push(tmp2/tmp1);
            }else{
                stack.push(Integer.valueOf(t));
            }
        }
        return stack.peek();
    }
}
